package com.ellricky.teacher.ui.mycourse.workjoin

import android.view.View
import android.widget.AdapterView
import com.andr.common.http.callback.BaseCallback
import com.andr.common.ui.adapter.BaseRecyclerAdapter
import com.andr.common.ui.mvp.BasePresenter
import com.ellricky.baselib.http.callback.EListCallback
import com.ellricky.baselib.ui.base.BaseRefreshActivity
import com.ellricky.baselib.util.EAppUtil
import com.ellricky.teacher.API_WORK_JOIN_LIST
import com.ellricky.teacher.R
import com.ellricky.teacher.WorkJoinAdapter
import com.ellricky.teacher.WorkJoinEntity

class WorkJoinListActivity : BaseRefreshActivity<Void, BasePresenter<Void>, WorkJoinEntity>() {


    override fun initUIView() {
        super.initUIView()
        mTvTitle.setText(R.string.tc_work_join)
        setRightBtn(0)
    }

    override fun getResponseCallback(): BaseCallback {
        return object : EListCallback<WorkJoinEntity>(this) {
            override fun onSuccess(data: MutableList<WorkJoinEntity>?, msg: String?) {
                dataSource = data
                rvView.onLoadFinish(dataSource, refresh)
            }

            override fun onErrorCode(code: String?, msg: String?) {
                super.onErrorCode(code, msg)
                rvView.onRefreshFailed(refresh)
            }

            override fun onHttpError(code: String?, msg: String?) {
                super.onHttpError(code, msg)
                rvView.onRefreshFailed(refresh)
            }
        }
    }

    override fun getRvAdapter(): BaseRecyclerAdapter<WorkJoinEntity> {
        return WorkJoinAdapter(this)
    }

    override fun getUrlPath(): String {
        return API_WORK_JOIN_LIST
    }


    override fun onItemClick(adapterView: AdapterView<*>?, view: View?, i: Int, l: Long) {
        super.onItemClick(adapterView, view, i, l)
        EAppUtil.jumpPageWithId(
                this, WorkJoinDetailActivity::class.java, adapter.get(i).id
        )
    }

    override fun onClickBtnRight() {
        super.onClickBtnRight()
        EAppUtil.jumpPageWithNoParam(this, WorkJoinCreateActivity::class.java)
    }

}
